package sample.project.component;

import com.qiplat.open.ui.widget.dialog.QiBottomDialog;
import com.rapid.api.Platform;
import com.rapid.api.project.Project;
import com.rapid.api.project.component.BaseComponent;
import com.rapid.api.project.component.Component;
import com.rapid.api.project.component.PersistenceConfig;
import com.rapid.api.project.component.StatePersistent;

/**
 * 首次打开项目显示对话框的组件
 */
public class FirstTimeDialog extends BaseComponent implements StatePersistent<FirstTimeDialog> {
    boolean isFirstTime = true;

    @Override
    public void didOpenProject(Project project) {
        if (isFirstTime) {
            isFirstTime = false;
            QiBottomDialog.show(Platform.getActivity(), "提示", "这是首次打开项目");
        }
    }

    @Override
    public FirstTimeDialog getState() {
        return this;
    }

    @Override
    public void loadState(FirstTimeDialog firstTimeDialog) {
        this.isFirstTime = firstTimeDialog.isFirstTime;
    }

    @Override
    public PersistenceConfig getPersistenceConfig() {
        return new PersistenceConfig(Project.FILE_PERSISTENCE_STORAGE);
    }
}
